package com.lijian.spi.manager;

import com.lijian.spi.Cache;

import java.util.Iterator;
import java.util.ServiceLoader;

/**
 * @author lj02
 * @desc
 * @date 2018/12/11
 */
public class CacheManager {

    private static Cache cache;

    static {
        ServiceLoader<Cache> load = ServiceLoader.load(Cache.class);
        Iterator<Cache> iterator = load.iterator();
        while (iterator.hasNext()) {
            cache = iterator.next();
        }
    }

    public static Cache getCache() {
        return cache;
    }
}
